﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace Demo1
{


    public class Player
    {

        public MapHandle _MapHandle;
        public double _X = 0;
        public double _Y = 0;

        public int _ID;

        public List<JobInfo> ProcessList = new List<JobInfo>();
        //public List<int> _DestroyProcessList = new List<int>();

        public Player(int ID)
        {
            _ID = ID;
            // 풀레이어당 맵오브젝트 하나를 생성했다
            _MapHandle = MapManager.I.Create();
        }

        public void AddProcess(IEnumerable pProcess, int id)
        {
            JobInfo pP = new JobInfo(id);
            pP.m_ProcessEnum = pProcess.GetEnumerator();

            ProcessList.Add(pP);

        }

        public void Update()
        {

            // 
            for (int index = ProcessList.Count - 1; index >= 0; index--)
            {
                JobInfo pProcess = ProcessList[index];

                if (pProcess.m_Condition != null)
                    if (pProcess.m_Condition.IsComplete() == false)
                    {// 선행작업이 완료되지 않았다.
                        continue;
                    }

                if (pProcess.m_ProcessEnum.MoveNext() == true)
                {

                    pProcess.m_Condition = (ICondition)pProcess.m_ProcessEnum.Current;
                    continue;

                }
                else
                {
                    ProcessList.Remove(pProcess);
                }
            }

        }

    }
}
